﻿namespace EasyToolkit.Excel.BindingTemplates
{
    using System.Collections.Generic;
    using ExcelInterop = Microsoft.Office.Interop.Excel;

    public interface IExcelBindingTemplateManager
    {
        /// <summary> Create a view.</summary>
        /// <param name="sheetContainer">The sheet that contains the description of the template to use.</param>
        /// <param name="templateName">The name of the template to use.</param>
        /// <param name="sheetDestination">The sheet where to render the view.</param>
        /// <param name="destinationRange">The first range where to render the view.</param>
        /// <param name="clearingCell">Optional: the cell uses to clear the view</param>
        /// <returns>The newly created view.</returns>
        IExcelTemplateView AddView(ExcelInterop.Worksheet sheetContainer, string templateName, ExcelInterop.Worksheet sheetDestination, ExcelInterop.Range destinationRange, string clearingCell = "A1");

        /// <summary> Create a view.</summary>
        /// <param name="sheetContainerName">The name of the sheet that contains the description of the template to use.</param>
        /// <param name="templateName">The name of the template to use.</param>
        /// <param name="sheetDestination">The sheet where to render the view.</param>
        /// <param name="destinationRange">The first range where to render the view.</param>
        /// <param name="clearingRange">Optional: the cell uses to clear the view</param>
        /// <returns>The newly created view.</returns>
        IExcelTemplateView AddView(string sheetContainerName, string templateName, ExcelInterop.Worksheet sheetDestination, ExcelInterop.Range destinationRange, string clearingCell = "A1");

        /// <summary> Remove and dispose a list of view.</summary>
        /// <param name="templates">The views to remove and dispose.</param>
        void RemoveViews(IList<IExcelTemplateView> views);

        /// <summary> Remove a view.</summary>
        /// <param name="template">The view to remove and dispose.</param>
        void RemoveView(IExcelTemplateView view);

        /// <summary> Get all the views owned by a given sheet.</summary>
        /// <param name="sheet">The source sheet.</param>
        /// <returns>The views owned by the sheet.</returns>
        List<IExcelTemplateView> GetSheetTemplateViews(ExcelInterop.Worksheet sheet);

        /// <summary> Rerender (description, style and data) the view given as parameter.</summary>
        /// <param name="templates">The views to refresh.</param>
        void Render(IExcelTemplateView view);
        
        /// <summary> Rerender (description, style and data) all the views given as parameters.</summary>
        /// <param name="templates">The views to refresh.</param>
        void Render(IEnumerable<IExcelTemplateView> views);

        /// <summary> Rerender only the data of the view given as parameter 
        /// (This implies that no change was made in the strucure of the data).</summary>
        /// <param name="templates">The views to refresh.</param>
        void RenderDataOnly(IExcelTemplateView view);

        /// <summary> Rerender only the data of all the views given as parameters 
        /// (This implies that no change was made in the strucure of the data).</summary>
        /// <param name="templates">The views to refresh.</param>
        void RenderDataOnly(IEnumerable<IExcelTemplateView> views);

        /// <summary> Clear the previously rendering view
        /// <param name="templates">The view to clear.</param>
        void ClearView(IExcelTemplateView view);
        
        /// <summary> Clear the previously rendering views
        /// <param name="templates">The views to clear.</param>
        void ClearViews(IEnumerable<IExcelTemplateView> views);
    }
}
